package com.ljw;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JFrame;

public class MainFrame extends JFrame {
	
	private Character character;
	
	public static void main(String[] args){
		MainFrame mainFrame = new MainFrame();
		mainFrame.setVisible(true);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainFrame.setBounds(100, 100, 300, 300);
		
		/*Canvas canvas = new Canvas();
		canvas.setBackground(Color.WHITE);//배경을 흰색으로
		canvas.setSize(300, 300);//크기는 550, 400
		
		mainFrame.add(canvas);*/
		
		mainFrame.run();
	}

	private void run() {
		Toolkit tk = Toolkit.getDefaultToolkit();
		character = new Character(tk);
	}

	private void draw(Graphics g) {
		//canvas를 여기서 참조해야한다.
		
		while(true){
			for(int i=0; i<character.getImg().length; i++){
				g.drawImage(character.getImg()[i], 100, 100, this);
				try{
					Thread.sleep(100);
					g.clearRect(0, 0, 300, 300);
				}catch(Exception e){
					e.printStackTrace();
				}
			}
		}
	}
	
	public void paint(Graphics g){
		draw(g);
	}
}